<template>
<div>
  <!--       企业信息查询-->
      <el-dialog
        width="95%"
        title="企业信息查询"
        :visible.sync="innerVisible"
        append-to-body
        @close="closeDialog">
        <el-row>
          <el-col>
        <el-form :model="queryParamsTwo" ref="queryFormEnter" size="small" :inline="true" v-show="showSearch" label-width="100px">
              <el-form-item label="企业名称/简称" prop="enterpriseName">
                <el-input
                  v-model="queryParamsTwo.deptName"
                  placeholder="请输入企业名称"
                  clearable
                  @keyup.enter.native="handleQueryEnter"
                />
              </el-form-item>
<!--              <el-form-item label="行政区域" prop="administrativeArea" >-->
<!--                <Treeselect v-model="queryParamsTwo.area" :options="options"  :flat="true" :show-count="true" :normalizer="normalizer"  placeholder="请选择行政区域"  style="width: 200px; float: left"/>-->
<!--              </el-form-item>-->
          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQueryEnter">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQueryEnter">重置</el-button>
          </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              plain
              icon="el-icon-plus"
              @click="SeasInfo"
            >转公海</el-button>
          </el-col>
        </el-row>
        <el-table  :row-style="{ height: '30px' }"  :cell-style="{ padding: '0px' }" border  v-loading="loading" :data="infoList" @selection-change="handleSelectionChangeEnter" @row-click="handleCurrentChange">
          <el-table-column type="selection" width="55" align="center" />
          <el-table-column label="序号" type="index" align="center" prop="index" :index="indexMethod"></el-table-column>
          <el-table-column label="创建时间" align="center" prop="createTime" :width="100">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="企业名称" align="center" prop="deptName" :show-overflow-tooltip="true">
          </el-table-column>
<!--          <el-table-column label="公司编号" align="center" prop="enterpriseAbbreviation" :show-overflow-tooltip="true"/>-->
          <el-table-column label="联系人" align="center" prop="contacts"/>
          <el-table-column label="联系电话" align="center" prop="phone" :show-overflow-tooltip="true"/>
<!--          <el-table-column label="行政区域" align="center" prop="area">-->
<!--            <template slot-scope="scope">-->
<!--              <dict-tag :options="dict.type.administrative_area" :value="scope.row.area"/>-->
<!--            </template>-->
<!--          </el-table-column>-->
          <el-table-column label="企业性质" align="center" prop="enterpriseNature" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.enterprise_nature" :value="scope.row.nature"/>
            </template>
          </el-table-column>
          <el-table-column label="所属行业" align="center" prop="industry" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.customer_industry" :value="scope.row.industry"/>
            </template>
          </el-table-column>
<!--          <el-table-column label="开户银行" align="center" prop="bankName" :show-overflow-tooltip="true"/>-->
<!--          <el-table-column label="税务号" align="center" prop="taxId" :show-overflow-tooltip="true"/>-->
          <el-table-column label="成立日期" align="center" prop="foundTime" width="120" :show-overflow-tooltip="true">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.foundTime, '{y}-{m}-{d}') }}</span>
            </template>
          </el-table-column>
          <el-table-column label="注册资金" align="center" prop="registeredFund" :show-overflow-tooltip="true"/>
<!--          <el-table-column label="状态" align="center" prop="status" >-->
<!--            <template slot-scope="scope">-->
<!--              <dict-tag :options="dict.type.honer_status" :value="scope.row.status"/>-->
<!--            </template>-->
<!--          </el-table-column>-->
          <el-table-column label="附件" align="center" prop="url" >
            <template slot-scope="scope">
              <div class="block" v-if="scope.row.url!=null">
                <el-image style="width: 50px; height: 50px" :src="scope.row.url">
                  <div slot="error" class="image-slot">
                    <i class="el-icon-picture-outline"></i>
                  </div>
                </el-image>
              </div>
            </template>
          </el-table-column>
          <el-table-column label="创建人" align="createBy" prop="createBy" />
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParamsTwo.pageNum"
          :limit.sync="queryParamsTwo.pageSize"
          @pagination="getListEnter"
        />
    </el-col>
  </el-row>
        <!--  点击触发荣誉资质信息-->
        <el-row>
          <el-col >
            <el-tabs v-model="activeName"  v-if="honorShow">
                    <el-tab-pane label="荣誉资质信息" name="first" >
                      <Honor v-if="honorShow"  :orgId="orgId" :isShow="'select'" :isOpen="true">
                      </Honor>
                    </el-tab-pane>
            </el-tabs>
          </el-col>
        </el-row>
      </el-dialog>
  <!--        企业信息查询弹出框结束-->
</div>
</template>

<style scoped lang="scss">

</style>

<script>
import {getOrgList} from "@/api/system/dept";
import { convertSeas} from "@/api/highSeas/seas";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listArea } from "@/api/area/area";
import FileView from "@/components/FileView/index"
import Honor from "../../honor/index.vue";
export default {
  components: {Honor,FileView,Treeselect},
  dicts: ['enterprise_nature','product_type',  'administrative_area','customer_industry','seas_status'],
  props: {
    innerVisible: Boolean,
    required: true
  },
  data(){
    return{
      // 企业信息表格数据
      infoList: [],
      queryParamsTwo: {
        pageNum: 1,
        pageSize: 15,
        deptName: null,
        area: null
      },
      //行政区域
      options:null,
      show:false,
      businessCode:"enterprise",
      typeSelect:0,
      total:0,
      showSearch:true,
      loading:true,
      //查看详情的弹出框
      dialogVisible:false,
      form:{},
      honorShow:false,
      deptId:null,
      deptName:null,
      orgId:null,
      activeName:"first"
    }
  },
  created() {
    this.getListEnter();
    this.area();
  },
  methods:{
    /** 查询机构企业信息列表 */
    getListEnter() {
      this.loading = true;
      getOrgList(this.queryParamsTwo).then(response => {
        console.log(response.rows)
        this.infoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    indexMethod(index) {
      return (this.queryParamsTwo.pageNum - 1) * this.queryParamsTwo.pageSize + index + 1;
    },
    SeasInfo(){
     if (!Array.isArray(this.enterId) || this.enterId.length === 0){
       this.$message.error("请选择企业信息");
     }else {
       convertSeas(this.enterId).then(res=>{
         if (res.code===200){
           this.$message.success("转换成功");
           this.innerVisible=false;

         }else {
           this.$message.error(res.msg);
           this.innerVisible=false;
         }
       });
     }
    },
    area(){
      listArea({}).then(response => {
        this.options = response.data;
      });
    },
    handleCurrentChange(row, index,column, event) {
      console.log(row.deptId)
      this.orgId = row.deptId;
      console.log(this.orgId)
      this.honorShow=true;
    },
    closeDialog(){
      this.$emit('close-dialog', false);
    },
    /** 搜索按钮操作 */
    handleQueryEnter() {
      this.queryParamsTwo.pageNum = 1;
      this.getListEnter();
    },
    //企业重置
    resetQueryEnter(){
      this.queryParamsTwo.deptName=null;
      this.queryParamsTwo.area=null;
      this.resetForm("queryFormEnter");
      this.handleQueryEnter();
    },
    //行政区域方法
    normalizer(node){
      if (node.children && !node.children.length) {
        delete node.children;
      }
      return {
        id:node.areaId,
        label:node.areaName,
        isDisabled:node.parentId=='000000'?true:false,
        children:node.list.length>0?node.list:0,

      }
    },
    // 多选框选中数据
    handleSelectionChangeEnter(selection) {
      this.enterId = selection.map(item => item.deptId)
      this.enterName = selection.map(item => item.deptName)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
  }
}
</script>
<style scoped lang="scss">
.no-multiple {

  // 隐藏多选
  ::v-deep .el-table_2_column_20 .is-center .el-table-column--selection .is-leaf .el-table__cell {
    display: none;
  }
}

</style>
